Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Graphics /
Chapter 2 - Geometric Shapes / Using Geometric Shapes


Editing Paths Parts

The GXGetPathParts and GXSetPathParts functions work similarly to the GXGetPolygonParts and GXSetPolygonParts functions, which are described in the previous section.

The sample function in Listing 2-31 creates a path shape similar to the polygon shape from the previous section. Later examples in this section use this path shape to demonstrate editing path parts.

Listing 2-31 Creating a path shape with two curved contours

void CreateTwoCurves(void)
{
   gxShape  aPathShape;

   static long twoCurveGeometry[] = {2, /* number of contours */
                                     3, /* number of points */
                                     0x40000000, /* 0100 ... */
                                     ff(100), ff(150), /* on */
                                     ff(50), ff(100),  /* off */
                                     ff(100), ff(50),  /* on */
                                     3, /* number of points */
                                     0x40000000, /* 0100 ... */
                                     ff(200), ff(50),   /* on */
                                     ff(250), ff(100),  /* off */
                                     ff(200), ff(150)}; /* on */
      

   aPathShape = GXNewPaths((gxPaths *) twoCurveGeometry);
   GXSetShapeFill(aPathShape, gxOpenFrameFill);

   GXDrawShape(aPathShape);

   GXDisposeShape(aPathShape);
}
The resulting path shape is shown in Figure 2-59.

Figure 2-59 A path shape with two curved contours

You can use the GXSetPathParts function to replace any number of geometric points from this path shape with an arbitrary number of new geometric points. In a manner similar to the GXSetPolygonParts function, the GXSetPathParts function requires that you encapsulate the new geometric points in a path geometry. For example, to replace the top two geometric points in the path shape shown in Figure 2-59 with a single geometric point, you must first encapsulate the new geometric point in a path geometry, as with the definition

static long newTopGeometry[] = {1, /* number of contours */
                                1, /* number of points */
                                0x00000000, /* 0000 ... */
                                ff(150), ff(50)}; /* on curve */
and then call the GXSetPathParts function:

GXSetPathParts(aPathsShape, 3, 2, 
               (gxPaths *) newTopGeometry, gxBreakNeitherEdit);
The resulting path shape is shown in Figure 2-60.

Figure 2-60 A path shape edited with GXSetPathParts

For more information about path geometries, see "Path Shapes" beginning on page 2-25.

For more information about the GXGetPathParts and GXSetPathParts functions, see the function descriptions on page 2-148 and page 2-149.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help